// ITI 1120 Winter 2012, Lab 2, Question 4
// Name: Dinesh B, Student# 1234567

import java.util.Scanner;

/**
 * This program finds the length of a line between two points
 * in an X-Y Cartesian plane.
 */

class Distance2Points
{
    public static void main (String[] args)
    {   
        // DECLARE VARIABLES/DATA DICTIONARY 

        double paX;      // X coordinate of point A
        double paY;      // Y coordinate of point A
        double pbX;      // X coordinate of point B
        double pbY;      // Y coordinate of point B
        
        double theDistance;  // distance between the 2 points

        // PRINT OUT IDENTIFICATION INFORMATION
        System.out.println("ITI 1120 Winter 2009, Lab 3, Question 4");
        System.out.println("Name: Dinesh B, #1234567");

        // READ IN GIVENS
     
        System.out.println( "Enter the coordinates of 2 points." );
        System.out.print( "   Point A, coord x = " );
        paX = ITI1120.readDouble( );
                
        System.out.print( "   Point A, coord y = " );
        paY = ITI1120.readDouble( );
                
        System.out.print( "   Point B, coord x = " );
        pbX = ITI1120.readDouble( );
                
        System.out.print( "   Point B, coord y = " );
        pbY = ITI1120.readDouble( );
                
        // Call method to use the method implementing the algorithm
        theDistance = calculateDistance(paX, paY, pbX, pbY);   
       
        // PRINT OUT RESULTS        
        System.out.println( "The distance between points A and B is " + theDistance );

    }


    // Method: computeLength
    // Descripition: Computes the length of the line.
    // Givens:  xA, yA   - coordinates of one end point of the line
    //          xB, yB   - coordintates of the other end point of the line
    private static double calculateDistance(double xA, double yA, double xB, double yB)
    {
     // Declaration of the result variable 
     double distance;  // distance between 2 points
     // The computation
     distance = Math.sqrt( Math.pow( xA - xB, 2) + Math.pow( yA - yB, 2 ) );
     // Return the result
     return(distance);
    }
     
} // Don't remove this brace bracket!
